package cn.avalon.controller;

import cn.avalon.domain.JsonResult;
import cn.avalon.domain.Movie;
import cn.avalon.dto.MovieDto;
import cn.avalon.dto.WatchMovieDto;
import cn.avalon.service.MovieService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @description: movie服务接口
 * @author: Avalon
 * @date: 2022年09月25日 ： 15:07
 * @version: ver1.0
 * @email 709785494@qq.com
 */
@RestController
@RequestMapping("/movie")
public class MovieController {

    @Autowired
    private MovieService movieService;

    @GetMapping("/{id}")
    public Movie findById(@PathVariable("id") Long id) {
       return movieService.findById(id);
    }

    @GetMapping
    public Movie findAll() {
        return movieService.findAll();
    }

    @PostMapping("/buy")
    public JsonResult buyMovie(@RequestBody MovieDto movieDto) {
        return movieService.buyMovie(movieDto);
    }

    @PostMapping("/watchMovie")
    public JsonResult watchMovie(@RequestBody WatchMovieDto watchMovieDto) {
        return movieService.watchMovie(watchMovieDto);
    }
}
